package springboot.Tools;

import com.mzlion.easyokhttp.HttpClient;

import java.util.Map;


public class HttpApi {

  public String address(String s) {
    return HttpClient
      // 请求方式和请求url
      .get("http://localhost:8080/" + s)
      .asString();
  }

  public String address(String s, Map<String, String> d) {
    StringBuilder url = new StringBuilder("http://localhost:8080/");
    if (s != null) {
      url.append(s);
    }
    if (d != null) {
      url.append("?");
      for (Map.Entry<String, String> entry : d.entrySet()) {
        url.append(entry.getKey()).append("=").append(entry.getValue());
      }
    }

    return HttpClient
      // 请求方式和请求url
      .get(String.valueOf(url))
      .asString();
  }


}
